// ----------------------------------------
// Filename: threads.h
// Description: The header file for threads
// Author: Jon Maloney
// Date: 9-May-2012
//

#ifndef _THREAD_H
#define _THREAD_H

//************************************************************
//                    Include .h files
//************************************************************
#include "scheduler.h"
#include "microRTOS.h"
//************************************************************
//                    Include external references
//************************************************************

//************************************************************
//                    Define Statements
//************************************************************

#define Thread_Delay Scheduler_Delay

//************************************************************
//                    Struct, Union, enum Statements
//************************************************************

//************************************************************
//                    Global variables and constants
//************************************************************

//************************************************************
//                    Prototype Global Functions
//************************************************************

// ----------------------------------------
// Thread_Create
// 
// Allocates memory and sets up the stack for a new task.
//	The new task is then added to the ready queue.
// Input:
//	firstThreadFunction:	The first funciton that the thread will run
//							when created.
//  functionArgument:		An argument that can be passed to the thread.
//							The argument can be of any type. When the thread
//							is run the funcitonArgument must be typecast back
//							to its appropriate type before it can be used.
//	stackSize:				The size in bytes of the stack to be used by the
//							task.
//	priority				The tasks priority. The task priority can be of any
//							value > 0 and < configNB_PRIORITY_LEVELS (found in configuraiton.h).
//							Priorities are in assending order, that is a task
//							with a priority of 8 will have higher priority than 
//							a task of priorty 7.
//							If the user assignes a priorty level higher than configKERNEL_INTERRUPT_PRIORITY
//							the task will re-assign the priority to be equal to configKERNEL_INTERRUPT_PRIORITY.
// Output:
//  A handle to the thread control block (TCB) that was created.
// Conditions:
// 	none
//
TCB * Thread_Create(void *firstThreadFunction, void *functionArgument, UINT8 stackSize, PRIORITY priority);

// ----------------------------------------
// Thread_Create
// 
// Allocates memory and sets up the stack for a new task.
//	The new task is then added to the ready queue.
// Input:
//	threadToDelete: A pointer to the thread to be deleted.
// Output:
//  none
// Conditions:
// 	none
//
void Thread_Delete(TCB * threadToDelete);

#endif
